#ifndef ANIMATION_H
#define ANIMATION_H

#include <QPixmap>
#include <qlist.h>
#include <qpainter.h>
#include <qvector2d.h>
class Animation
{
public:
    Animation(int speed=500);
    //添加帧图
    void addFrame(const QString& filename);
    QPixmap getFrame(int index)const;
    qsizetype count()const;
    void update();
    void draw(QPainter*painter);
    void setPos(const QVector2D&pos);

    inline bool finished()const{return index==count()-1;}

private:
    QList<QPixmap> pixmaps;
    int xPos=-100;
    int yPos=-100;
    int index=0;
    int speed=500;

};

#endif // ANIMATION_H
